var login = {};

login.onload = function() {
	$("#btnLogin").bind("click", function() {
		login.doLogin();
	});
};

login.doLogin = function() {
	var name = $("#username").val();
	var pwd = $("#password").val();
	var url = "checkUser.action";
	var params = {username:name,pwd:pwd};
	$.ajax({
		type:"POST",
		dataType:"json",
		url:url,
		data:params,
		success:function(jsonData) {
			if (jsonData == "success") {
				$("#loginMsg").text("congratulations! you can login");
				window.location.href = "toSamples.action";
			} else {
				$("#loginMsg").text("invalid user name or password");
			}
		}
	});
};